'''
3个瓶子可以换1瓶水，
剩下2个可以找老板借一个，换1瓶水，但最后一定要还给老板
'''

from typing import List

def num_bottle(bottles: List[int]):
    res = []
    for n0 in bottles:
        if n0 < 2: return 0

        n_pre = n0 // 3
        n_back = n_pre + n0 % 3

        def back(n_back):
            # print('Y')
            temp01 = 0
            if n_back < 2: return 0
            if n_back == 2: return 1

            temp01 += n_back // 3
            print(temp01)
            back02 = temp01 + n_back % 3
            if back02 >= 2:
                temp01 += back(back02)
            return temp01

        temp_res = n_pre + back(n_back)
        res.append(temp_res)
    return res

while True:
    try:
        bottles = []
        for i in range(10):
            a = int(input())
            if a == 0:
                break
            bottles.append(a)
        print(bottles)
        res = num_bottle(bottles)
        for i in res:
            print(i)
    except:
        break